package org.alys114.springcloud.pbook.client;

import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.stereotype.Component;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestParam;

/**
 * @author: Vincent.chan
 * @date: 2019/10/1 21:43
 * @version: v1.0
 * @Description: pmember微服务的Feign客户端
 */

// 指明fallback的处理类
@FeignClient(name = "pmember",fallback = MemberClient.MemberClientFallback.class)
public interface MemberClient {
    @GetMapping("/check")
    MemberRestResult checkMobile(@RequestParam("mobile") String mobile);

    // 自动加载到Ioc容器
    @Component
    static class MemberClientFallback implements MemberClient{

        @Override
        public MemberRestResult checkMobile(String mobile) {
            MemberRestResult mr = new MemberRestResult();
            mr.setCode("0");
            mr.setMsg("success");
            MemberDTO dto = new MemberDTO();
            dto.setMid(0);
            mr.setData(dto);
            return mr;
        }
    }
}
